package com.htc.android.footprints.activity;

import android.app.LocalActivityManager;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import com.htc.android.footprints.commonui.HtcDialog;
import com.htc.android.footprints.provider.FootprintManager;
import com.htc.android.footprints.utils.FootprintUtils;
import com.htc.android.footprints.utils.SettingInfo;
import com.htc.android.footprints.utils.StorageUtil;
import com.htc.android.footprints.utils.StorageUtil.OnChangeStorageListener;
import com.htc.android.footprints.vo.Category;
import com.htc.android.footprints.vo.Footprint;
import com.htc.widget.HtcAlertDialog;
import com.htc.widget.TabSwitchActivity;
import com.htc.widget.TabSwitchHost;
import com.htc.widget.TabSwitchHost.OnTabChangeSpecialListener;
import com.htc.widget.TabSwitchHost.TabContentFactory;
import com.htc.widget.TabSwitchHost.TabSpec;
import java.util.ArrayList;
import java.util.Iterator;

public class WrapShowOnMapActivity extends TabSwitchActivity
{
  public static final int MENU_FITALL = 1;
  public static final int MENU_MY_LOCATION = 2;
  public static final int MENU_SEARCH = 3;
  public static final int MENU_SHOW_LISTVIEW = 0;
  private static final String TAG = "WrapShowOnMapActivity";
  private Category curCategory;
  private FootprintManager dbManager;
  private ShowOnMapActivity mActivity;
  private View mDecorView;
  private TabSwitchHost mPanelHost;
  private StorageUtil mStorageUtil;

  private void checkWirelessNetwork()
  {
    int i = 0;
    ConnectivityManager localConnectivityManager = (ConnectivityManager)getSystemService("connectivity");
    if (localConnectivityManager != null)
    {
      NetworkInfo localNetworkInfo = localConnectivityManager.getActiveNetworkInfo();
      if ((localNetworkInfo != null) && (localNetworkInfo.getState() == NetworkInfo.State.CONNECTED))
        i = 1;
    }
    if (i == 0)
      new HtcDialog(this).getWirelessDisabledDialog().show();
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    requestWindowFeature(1);
    getWindow().setBackgroundDrawable(null);
    if (SettingInfo.getInstance(this).showConnectionFailedAlert)
      checkWirelessNetwork();
    Intent localIntent1 = getIntent();
    setContentView(2130903079);
    this.mPanelHost = getTabHost();
    getResources();
    this.dbManager = FootprintManager.getInstance(getApplicationContext());
    ArrayList localArrayList = this.dbManager.getAllCategory();
    localArrayList.add(0, Category.getAllCategory());
    int i = localIntent1.getIntExtra("tab_index", 0);
    Intent localIntent2 = new Intent("com.htc.android.footprints.activity.ShowOnMapActivity");
    localIntent2.putParcelableArrayListExtra("display", localIntent1.getParcelableArrayListExtra("display"));
    Footprint localFootprint = (Footprint)localIntent1.getParcelableExtra("target");
    if (localFootprint != null)
    {
      Category localCategory1 = new Category();
      localCategory1.mKeyword = localFootprint.mCategory;
      i = localArrayList.indexOf(localCategory1);
    }
    Category localCategory2 = (Category)localArrayList.get(i);
    localIntent2.putExtra("category", localCategory2);
    this.mDecorView = getLocalActivityManager().startActivity("ShowOnMapActivity", localIntent2).getDecorView();
    this.mActivity = ((ShowOnMapActivity)this.mLocalActivityManager.getCurrentActivity());
    Iterator localIterator = localArrayList.iterator();
    while (localIterator.hasNext())
    {
      Category localCategory3 = (Category)localIterator.next();
      TabSwitchHost localTabSwitchHost2 = this.mPanelHost;
      TabSwitchHost.TabSpec localTabSpec = this.mPanelHost.newTabSpec(localCategory3.mKeyword).setIndicator(localCategory3.mName, FootprintUtils.getTabCategoryIcon(getApplicationContext(), localCategory3.mKeyword), FootprintUtils.getInverseCategory(getApplicationContext(), localCategory3.mKeyword), FootprintUtils.getCategoryOverlayIcon(getApplicationContext(), localCategory3.mKeyword));
      1 local1 = new TabSwitchHost.TabContentFactory()
      {
        public View createTabContent(String paramString)
        {
          return WrapShowOnMapActivity.this.mDecorView;
        }
      };
      localTabSwitchHost2.addTab(localTabSpec.setContent(local1));
    }
    if (localFootprint != null)
    {
      Handler localHandler = new Handler();
      2 local2 = new Runnable(localFootprint, localCategory2)
      {
        public void run()
        {
          if (WrapShowOnMapActivity.this.mActivity != null)
            WrapShowOnMapActivity.this.mActivity.moveTo(this.val$targetFootprint, this.val$targetCategory);
        }
      };
      localHandler.postDelayed(local2, 600L);
    }
    this.mPanelHost.setCurrentTab(i);
    this.mPanelHost.setTabHintEnabled(true);
    TabSwitchHost localTabSwitchHost1 = this.mPanelHost;
    3 local3 = new TabSwitchHost.OnTabChangeSpecialListener()
    {
      public void onTabBeforeChange(String paramString)
      {
      }

      public void onTabChanged(String paramString)
      {
        if (paramString.equals(Category.getAllCategory().mKeyword))
          WrapShowOnMapActivity.access$202(WrapShowOnMapActivity.this, Category.getAllCategory());
        while (true)
        {
          WrapShowOnMapActivity.this.mActivity.setCategory(WrapShowOnMapActivity.this.curCategory);
          return;
          WrapShowOnMapActivity.access$202(WrapShowOnMapActivity.this, WrapShowOnMapActivity.this.dbManager.findCategory(paramString));
        }
      }
    };
    localTabSwitchHost1.setOnTabChangedListener(local3);
    this.mStorageUtil = new StorageUtil(getApplicationContext());
    StorageUtil localStorageUtil = this.mStorageUtil;
    4 local4 = new StorageUtil.OnChangeStorageListener()
    {
      public void onStorageChanged(int paramInt)
      {
        if (paramInt > 1)
          WrapShowOnMapActivity.this.startActivity(FootprintUtils.getResetIntent());
      }
    };
    localStorageUtil.SetOnChangeStorageListerner(local4);
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    paramMenu.add(0, 0, 0, getString(2131361881)).setIcon(2130837728);
    paramMenu.add(0, 1, 1, getString(2131361879)).setIcon(2130837729);
    paramMenu.add(0, 2, 2, getString(2131361962)).setIcon(2130837730);
    return true;
  }

  public void onDestroy()
  {
    this.mDecorView = null;
    this.mActivity.finish();
    this.mActivity = null;
    this.mPanelHost.clearAllTabs();
    this.mPanelHost.setOnTabChangedListener(null);
    this.mPanelHost.removeAllViews();
    this.mPanelHost = null;
    this.mStorageUtil = null;
    this.dbManager = null;
    super.onDestroy();
  }

  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if (paramInt == 84)
    {
      Intent localIntent = new Intent(this, SearchActivity.class);
      if (this.curCategory != null)
        localIntent.putExtra("EXTRA_CATEGORY", this.curCategory.mKeyword);
      startActivity(localIntent);
    }
    for (boolean bool = true; ; bool = super.onKeyDown(paramInt, paramKeyEvent))
      return bool;
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    switch (paramMenuItem.getItemId())
    {
    default:
    case 0:
    case 1:
    case 2:
    }
    while (true)
    {
      return true;
      Intent localIntent = new Intent("com.htc.android.footprints.ListModeActivity");
      localIntent.addFlags(4194304);
      localIntent.addFlags(67108864);
      localIntent.putExtra("CATEGORY", this.curCategory);
      startActivity(localIntent);
      continue;
      this.mActivity.fitAll();
      continue;
      this.mActivity.showMyLocation();
    }
  }

  protected void onPause()
  {
    super.onPause();
    if (this.mStorageUtil != null)
      this.mStorageUtil.closeStorgaeUtil();
  }

  public boolean onPrepareOptionsMenu(Menu paramMenu)
  {
    paramMenu.getItem(1).setEnabled(this.mActivity.isEmpty());
    return true;
  }

  protected void onResume()
  {
    super.onResume();
    if (this.mStorageUtil != null)
      this.mStorageUtil.startStorageUtil();
  }
}

/* Location:           E:\workspace\dex2java\dex-translator-0.0.9.3\HtcFootprints_dex2jar.jar
 * Qualified Name:     com.htc.android.footprints.activity.WrapShowOnMapActivity
 * JD-Core Version:    0.6.0
 */